import { IResCartlist } from '@/types/cart'
import { sphHttp } from '@/utils/request'

/**
 * @description 请求购物车列表
 * @returns Promise
 */
export const reqCartList = () => {
  return sphHttp<IResCartlist[]>('/api/cart/cartList', 'GET')
}

/**
 * @description 请求更改购物车的单个状态
 * @param skuID 商品id
 * @param isChecked 商品的选中状态
 * @returns
 */
export const reqChangeGoodSingle = (skuID: number | string, isChecked: number | string) => {
  return sphHttp(`/api/cart/checkCart/${skuID}/${isChecked}`, 'GET')
}


/**
 * @description 购物车的全选与取消全选
 * @param isChecked 是否选中
 * @returns
 */
export const reqChangeGoodsAll = (params: any, isChecked: number) => {
  return sphHttp(`/api/cart/batchCheckCart/${isChecked}`, 'POST', params)
}



/**
 * @description 删除单个商品
 * @param skuID 删除需要的id
 * @returns Promise
 */
export const reqDeleteSingle = (skuID:number|string)=>{
  return sphHttp(`/api/cart/deleteCart/${skuID}`,"DELETE")
}



/**
 * @description 请求添加到购物车
 * @param skuID 需要添加的id
 * @param skuNum 需要添加的数量
 * @returns 
 */
export const reqaddCart = (skuID:number|string,Num:number|string)=>{
  return sphHttp(`/api/cart/addToCart/${skuID}/${Num}`,"POST")
}


